from pydantic import BaseModel
from typing import Optional, List

# 联系方式相关schemas
class ContactBase(BaseModel):
    name: str
    type: str
    url: str
    icon: str = ""
    status: bool = True

class ContactCreate(ContactBase):
    pass

class ContactUpdate(BaseModel):
    name: Optional[str] = None
    type: Optional[str] = None
    url: Optional[str] = None
    icon: Optional[str] = None
    status: Optional[bool] = None

class Contact(ContactBase):
    id: int
    
    class Config:
        from_attributes = True

# 链接分类相关schemas
class LinkCategoryBase(BaseModel):
    name: str
    status: bool = True
    is_builtin: bool = False

class LinkCategoryCreate(LinkCategoryBase):
    pass

class LinkCategoryUpdate(BaseModel):
    name: Optional[str] = None
    status: Optional[bool] = None

class LinkCategory(LinkCategoryBase):
    id: int
    
    class Config:
        from_attributes = True

# 网站链接相关schemas
class LinkBase(BaseModel):
    name: str
    category_id: Optional[int] = None
    url: str
    icon: str = ""
    description: Optional[str] = None
    status: bool = True

class LinkCreate(LinkBase):
    pass

class LinkUpdate(BaseModel):
    name: Optional[str] = None
    category_id: Optional[int] = None
    url: Optional[str] = None
    icon: Optional[str] = None
    description: Optional[str] = None
    status: Optional[bool] = None

class Link(LinkBase):
    id: int
    
    class Config:
        from_attributes = True

# 标签相关schemas
class TagBase(BaseModel):
    name: str
    status: bool = True

class TagCreate(TagBase):
    pass

class TagUpdate(BaseModel):
    name: Optional[str] = None
    status: Optional[bool] = None

class Tag(TagBase):
    id: int
    
    class Config:
        from_attributes = True

# 标题相关schemas
class TitleBase(BaseModel):
    content: str
    status: bool = True

class TitleCreate(TitleBase):
    pass

class TitleUpdate(BaseModel):
    content: Optional[str] = None
    status: Optional[bool] = None

class Title(TitleBase):
    id: int
    
    class Config:
        from_attributes = True

# 搜索引擎相关schemas
class SearchEngineBase(BaseModel):
    name: str
    url: str
    icon: str = ""
    status: bool = True

class SearchEngineCreate(SearchEngineBase):
    pass

class SearchEngineUpdate(BaseModel):
    name: Optional[str] = None
    url: Optional[str] = None
    icon: Optional[str] = None
    status: Optional[bool] = None

class SearchEngine(SearchEngineBase):
    id: int
    
    class Config:
        from_attributes = True

# 网站配置相关schemas
class WebsiteConfigBase(BaseModel):
    site_name: str = ""
    site_description: str = ""
    personal_intro: str = ""
    icp_record: str = ""
    copyright_info: str = ""
    background_effect: str = "gradient"
    background_image_url: str = ""

class WebsiteConfigCreate(WebsiteConfigBase):
    pass

class WebsiteConfigUpdate(BaseModel):
    site_name: Optional[str] = None
    site_description: Optional[str] = None
    personal_intro: Optional[str] = None
    icp_record: Optional[str] = None
    copyright_info: Optional[str] = None
    background_effect: Optional[str] = None
    background_image_url: Optional[str] = None

class WebsiteConfig(WebsiteConfigBase):
    id: int
    
    class Config:
        from_attributes = True

# 用户相关schemas
class UserBase(BaseModel):
    username: str

class UserCreate(UserBase):
    password: str

class User(UserBase):
    id: int
    
    class Config:
        from_attributes = True

# 令牌相关schemas
class Token(BaseModel):
    access_token: str
    token_type: str

class TokenData(BaseModel):
    username: Optional[str] = None

# 分页相关schemas
class PaginationMeta(BaseModel):
    current_page: int
    total_pages: int
    total_items: int
    page_size: int

class PaginatedResponse(BaseModel):
    items: List[BaseModel]
    meta: PaginationMeta